import React from "react";
import BaseChart from "../Base";
import { ChartProps } from "../interface";
import transform from "./transform";

export interface PieChartConfig {
  /**
   * label字段
   */
  labelField: string;
  /**
   * value字段
   */
  valueField: string;
}

export interface PieChartProps extends ChartProps {
  config: PieChartConfig;
  data: any[];
}

const PieChart: React.FC<PieChartProps> = ({ ...props }) => {
  const { data, config } = props;
  const option = transform(data, config);

  return <BaseChart {...props} option={option} />;
};

PieChart.displayName = "PieChart";

export default PieChart;
